<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'新建收入'))}
	<div class="frame">
		<form method='post' id="form_data" name="form_data" enctype="multipart/form-data"   >
			<input type="hidden" id="ajax" name="ajax" value="0">
			<input type="hidden" id="account_name" name="account_name" value="">
			<input type="hidden" id="doc_type" name="doc_type" value="1">
			<input type="hidden" id="opmode" name="opmode" value="add">
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="doc_no">单据编号：</label>
						
							<p class="input-static">
								YYYY-####
							</p>
						</div>
					</div>
				</div>
				<div class="box col-12">
					
						<label class="input-label" for="end_date" >日期：</label>
						
							<input  class="input input-date" type="text" id="input_date" name="input_date"    check="required" info="请输入日期" readonly="readonly">
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="partner">客户名称：</label>
						<div class="input-block x-select">
							<select id="partner" name="partner" class="input" check="required" info="请选择客户">
								<option value="" >请选择客户</option>
								{:fill_option($customer_list)}
								{:fill_option($supplier_list)}
								<option value="其他" >其他</option>
							</select>
						</div>
					</div>
				</div>
				<div class="box col-12">
					
						<label class="input-label" >收入项目：</label>
						<div class="input-block x-select">
							<select id="type" name="type" class="input" check="required" info="请选择收收入项目">
								<option value="" >请选择收入项目</option>
								{:fill_option(get_system_config('finance_income_type'))}
								<option value="其他" >其他</option>
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="account_id">收款帐号：</label>
						<div class="input-block x-select">
							<select id="account_id" name="account_id" class="input" check="required" info="请选择收款帐号">
								<option value="" >请选择收款帐号</option>
								{:fill_option($account_list)}
							</select>
						</div>
					</div>
				</div>
				<div class="box col-12">
					
						<label class="input-label" >账户余额：</label>
						
							<input class="input" id="balance" name="balance" type="text" readonly="readonly" >
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="income">金额：</label>
						
							<input class="input" type="text" name="income" id="income" check="required" info="请输入金额">
						</div>
					</div>
				</div>
				<div class="box col-12">
					
						<label class="input-label" for="actor_name">经办人：</label>
						
							<input class="input" type="text" id="actor_name" name="actor_name" check="required" info="请输入经办人">
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="name">附件：</label>
						
							{:widget('file_upload/add')}
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="remark">摘要：</label>
						
							<textarea name="remark" rows="4" style="width: 100%;" check="required" info="请输入摘要" class="textarea"></textarea>
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="remark"></label>
						
							<a class="btn btn-normal" onclick="save()">保存</a>
							<a class="btn btn-return" onclick="go_return_url()">取消 </a>
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>
</block>
<block name="js">
	<script>
		layui.use(['global', 'editor'], function() {
			var $ = layui.jquery;
			set_return_url();

			$("#btn_save").on('click', function() {
				send_form("form_data", "{:url('save')}", "{:url('index')}",function(ret){
					console.log(ret);
				});
			});
			
			$(document).ready(function() {
				$("#account_id").change(function() {
					$account_name = $('#account_id option:selected').text();
					$("#account_name").val($account_name);
					$.getJSON("{:url('Finance/read_account')}", {
						account_id : $(this).val()
					}, function(data) {
						if (data.status == 1) {
							$("#balance").val(data.data.balance);
						}
					});
				});
			});
		});

	</script>

</block>